package com.example.newproject_overseas.Screen

import android.annotation.SuppressLint
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme.colors
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.scale
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.example.newproject_overseas.R
import com.example.newproject_overseas.components.TopApp

@OptIn(ExperimentalMaterial3Api::class)
@SuppressLint("UnrememberedMutableState")
@Composable
fun Bank(navController: NavHostController) {
    var IFSCCode by remember { mutableStateOf("") }
    var BankNumber by remember { mutableStateOf(TextFieldValue()) }

    Box(
        modifier = Modifier
            .fillMaxSize()
            .background(color = Color(0XFFEFF0F3))
    ) {

        Column(
            modifier = Modifier
                .fillMaxSize()
                .background(color = Color(0XFFEFF0F3)),

            ) {

            TopApp(title = "Bank", navController = navController)

            LazyColumn(
                modifier = Modifier.padding(horizontal = 12.dp)
            ) {

                item {
                    Box(
                        modifier = Modifier
                            .padding(top = 20.dp)
                            .shadow(7.5.dp, shape = RoundedCornerShape(7.5.dp), clip = true)
                            .fillMaxWidth()
                            .height(50.dp)
                            .clip(RoundedCornerShape(7.5.dp)) // 设置圆角为36dp
                            .background(Color.White)
                    ) {
                        Row(
                            modifier = Modifier
                                .padding(top = 15.dp)
                                .padding(horizontal = 20.dp)
                        ) {
                            Text(text = "Occupation")
                            Spacer(modifier = Modifier.weight(1f))
                            Image(
                                painter = painterResource(id = R.drawable.go_in),
                                contentDescription = null,
                                modifier = Modifier
                                    .width(20.dp)
                                    .height(20.dp)
                                    .scale(0.9f)
                            )
                        }
                    }
                    Box(
                        modifier = Modifier

                            .padding(top = 20.dp)
                            .shadow(7.5.dp, shape = RoundedCornerShape(7.5.dp), clip = true)
                            .fillMaxWidth()

                            .clip(RoundedCornerShape(7.5.dp)) // 设置圆角为36dp
                            .background(Color.White)
                    ) {
                        Column(
                            modifier = Modifier
                                .padding(10.dp)
                                .fillMaxWidth()
                                .background(Color(0xFFF1F1F1))
                                .padding(vertical = 15.dp, horizontal = 15.dp)
                        ) {
                            Row(verticalAlignment = Alignment.CenterVertically) {
                                Text(text = "Bank Number")
                                Spacer(modifier = Modifier.weight(1f))
                                //接收用户输入的值
                                TextField(
                                    value = BankNumber, //输入的默认值
                                    onValueChange = { //当输入的有变化时将输入的赋值给name
                                        BankNumber = it
                                    },
                                    placeholder = {
                                        Text(text = "Please enter Bank Number")
                                    },
                                    colors = TextFieldDefaults.textFieldColors(
                                        containerColor = Color.Transparent,
                                        focusedIndicatorColor = Color.Transparent,
                                        disabledIndicatorColor = Color.Transparent,
                                        unfocusedIndicatorColor = Color.Transparent,
                                    )
                                )
                            }
                            Spacer(modifier = Modifier.height(10.dp))
                            Row(
                                verticalAlignment = Alignment.CenterVertically
                            ) {
                                Text(text = "IFSC Code")
                                Spacer(modifier = Modifier.weight(1f))
                                //接收用户输入的值
                                TextField(
                                    value = IFSCCode, //输入的默认值
                                    onValueChange = { //当输入的有变化时将输入的赋值给name
                                        IFSCCode = it
                                    },
                                    placeholder = {
                                        Text(text = "Please enter IFSC Code")
                                    },
                                    keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),//键盘的设置
                                    colors = TextFieldDefaults.textFieldColors(
                                        containerColor = Color.Transparent, // 设置背景颜色为红色
                                        focusedIndicatorColor = Color.Transparent,
                                        disabledIndicatorColor = Color.Transparent,
                                        unfocusedIndicatorColor = Color.Transparent,
                                    )
                                )


                            }


                        }

                    }


                }

            }

        }

        //底部按钮
        Button(
            onClick = { /*TODO*/ }, modifier = Modifier
                .fillMaxWidth(1f)
                .height(44.dp)
                .align(Alignment.BottomCenter),
            colors = ButtonDefaults.buttonColors(Color(0xFFFFCC00)),
            shape = RoundedCornerShape(4.5.dp)
        ) {
            androidx.compose.material.Text(
                modifier = Modifier,
                text = "Submit",
                color = Color(0xFFFFFFFF),
                fontSize = 20.sp
            )
        }


    }

}

@Preview
@Composable
fun BankPreview() {
    val navController = rememberNavController() // 假设这里使用了导航控制器
    Bank(navController)
}

